package com.hhkj.study.api.user.controller;

import com.hhkj.study.api.user.model.req.ApiCustomerUserCourseBaseReq;
import com.hhkj.study.api.user.model.req.ApiCustomerUserExerciseSaveReq;
import com.hhkj.study.api.user.model.req.ApiCustomerUserExerciseTrainReq;
import com.hhkj.study.api.user.sevice.biz.ApiCustomerUserExerciseBizService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.framework.login.api.ApiLoginOpen;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author luowu
 * @Date 2024/9/27 涵 15:39:37
 */
@RestController
@RequestMapping("/api/user/exercise")
public class ApiCustomerUserExerciseController {

    @Resource
    private ApiCustomerUserExerciseBizService apiUserExerciseBizService;


    /**
     * 练习记录
     * @param req
     * @return
     */
    @PostMapping("/list")
    public AjaxResult list(@Validated @RequestBody ApiCustomerUserCourseBaseReq req) {
        return AjaxResult.success(apiUserExerciseBizService.list(req));
    }

    /**
     * 做题
     * @param req
     * @return
     */
    @PostMapping("/doExercise")
    public AjaxResult doExercise(@Validated @RequestBody ApiCustomerUserExerciseTrainReq req) {
        return AjaxResult.successData(apiUserExerciseBizService.doExercise(req));
    }
    /**
     * 建培圈系统提交练习后回调
     * @param req
     * @return
     */
    @ApiLoginOpen
    @PostMapping("/callback/save")
    public AjaxResult save(@Validated @RequestBody ApiCustomerUserExerciseSaveReq req) {
        return AjaxResult.success(apiUserExerciseBizService.save(req));
    }
}
